'use strict'
let Koa = require('koa');
let bodyparser = require('koa-bodyparser');
let stricts = require('koa-static');
let temp = require('./main');
// let models = require('./models');
let controllers = require('./controllers');
//初始化一个web服务器实例
let models=require('./models');
let session=require('./session');
let app = new Koa();


app.use(session(app));
//处理静态文件
app.use(stricts(__dirname+'/static'));

//注册中间键
app.use(bodyparser());

//引用中间键
app.use(temp);

//注册自定义路由的中间键
app.use(controllers());

(async()=>{
      await models.sync();
})()


let pron = 5012;

app.listen(pron);

 console.log(`路由地址:http://127.0.0.1:${pron}`);
// console.log(`http://localhost:${pron}`);